package li.buda.blueprint.blazeds.server.component;

import flex.messaging.MessageException;
import flex.messaging.messages.ErrorMessage;
import org.springframework.flex.core.ExceptionTranslator;

/**
 * Created by IntelliJ IDEA.
 * User: Piotrek
 * Date: 2010-03-28
 * Time: 15:49:27
 * To change this template use File | Settings | File Templates.
 */
public class RemoteServiceExceptionTranslator implements ExceptionTranslator {
    public boolean handles(Class<?> clazz) {
        return clazz.equals(RemoteServiceException.class);
    }

    public MessageException translate(Throwable t) {
        MessageException ex = new MessageException();
        ex.setCode(((MessageException) t).getCode());
        ex.setMessage(t.getMessage());
        ex.setRootCause(t);
        return ex;
    }
}
